<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    1073. Number of Enclaves
   </h1>
   <p>
    Given a 2D array
    <code>
     A
    </code>
    , each cell is 0 (representing sea) or 1 (representing land)
   </p>
   <p>
    A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid.
   </p>
   <p>
    Return the number of land squares in the grid for which we
    <strong>
     cannot
    </strong>
    walk off the boundary of the grid in any number of moves.
   </p>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input: </strong><span id="example-input-1-1">[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]</span>
<strong>Output: </strong><span id="example-output-1">3</span>
<strong>Explanation: </strong>
There are three 1s that are enclosed by 0s, and one 1 that isn't enclosed because its on the boundary.</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input: </strong><span id="example-input-2-1">[[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]</span>
<strong>Output: </strong><span id="example-output-2">0</span>
<strong>Explanation: </strong>
All 1s are either on the boundary or can reach the boundary.
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     Note:
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= A.length &lt;= 500
     </code>
    </li>
    <li>
     <code>
      1 &lt;= A[i].length &lt;= 500
     </code>
    </li>
    <li>
     <code>
      0 &lt;= A[i][j] &lt;= 1
     </code>
    </li>
    <li>
     All rows have the same size.
    </li>
   </ol>
  </div>
  <div>
   <h1 class="question_title">
    1073. 飞地的数量
   </h1>
   <p>
    给出一个二维数组&nbsp;
    <code>
     A
    </code>
    ，每个单元格为 0（代表海）或 1（代表陆地）。
   </p>
   <p>
    移动是指在陆地上从一个地方走到另一个地方（朝四个方向之一）或离开网格的边界。
   </p>
   <p>
    返回网格中
    <strong>
     无法
    </strong>
    在任意次数的移动中离开网格边界的陆地单元格的数量。
   </p>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     示例 1：
    </strong>
   </p>
   <pre><strong>输入：</strong>[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]
<strong>输出：</strong>3
<strong>解释： </strong>
有三个 1 被 0 包围。一个 1 没有被包围，因为它在边界上。</pre>
   <p>
    <strong>
     示例 2：
    </strong>
   </p>
   <pre><strong>输入：</strong>[[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]
<strong>输出：</strong>0
<strong>解释：</strong>
所有 1 都在边界上或可以到达边界。</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= A.length &lt;= 500
     </code>
    </li>
    <li>
     <code>
      1 &lt;= A[i].length &lt;= 500
     </code>
    </li>
    <li>
     <code>
      0 &lt;= A[i][j] &lt;= 1
     </code>
    </li>
    <li>
     所有行的大小都相同
    </li>
   </ol>
  </div>
 </body>
</html>